import Vue from 'vue'
import Router from 'vue-router'
//登录界面
import Login from '@/components/index/Login'
//消息界面
import MainIndex from '@/components/messages/Index'
//好友
import FriendList from '@/components/friend/Index'
//工作台
import Work from '@/components/works/Work'
//用户信息
import UserMain from '@/components/usermain/UserMain'
//知识台
import Learn from '@/components/knowledge/Learn'
//文件
import FilePage from '@/components/fileconsole/Index'

Vue.use(Router)

const router = new Router({
	mode: 'hash',
	routes: [
		{path: '/', component: Login},
		{path: '/Login', component: Login},
		{path: '/MainIndex', component: MainIndex},
		{path: '/FriendList', component: FriendList},
		{path: '/Work',component: Work},
		{path: '/Learn', component: Learn},
		{path: '/UserMain', component: UserMain},
		{path: '/FilePage', component: FilePage},
	]
});
//路由守卫
router.beforeEach(function(to, from, next){
//	var token = localStorage.getItem("appUserToken");
//	console.log(to.path);
//	if (to.path == '/Login' || to.path == '/') {
//		if(token == '' || token == null || token == 'undefined'){
//			localStorage.setItem("appUserToken", "");
//			next();
//		}else{
//			next({path: '/MainIndex'});
//		}
//	} else{
//		//是否在登录状态下
//		if(token == '' || token == null || token == 'undefined'){
//			next({path: '/Login'});
//		}else{
			next();
//		}
//	}
});
export default router;